using UnityEngine;

public class SpringboardScript : MonoBehaviour
{
	private float forceJump = 3f;

	private float vectorForward = 100f;

	private float maxVelocity = 25f;

	private string layerName = "dontUseAim";

	private void Start()
	{
		base.gameObject.layer = LayerMask.NameToLayer(layerName);
	}

	private void OnTriggerEnter(Collider other)
	{
		if (!other.tag.Equals("MyVehicle"))
		{
			return;
		}
		CarBehavior componentInParent = other.GetComponentInParent<CarBehavior>();
		if ((bool)componentInParent && !componentInParent.onSpringboardJump)
		{
			componentInParent.onSpringboardJump = true;
			componentInParent.springboardJumpStartPos = base.transform.position;
		}
		Rigidbody componentInParent2 = other.gameObject.GetComponentInParent<Rigidbody>();
		if (componentInParent2 != null)
		{
			componentInParent2.AddForce(other.gameObject.transform.forward * vectorForward + new Vector3(0f, forceJump, 0f), ForceMode.Acceleration);
			Vector3 velocity = componentInParent2.velocity;
			if (velocity.x > maxVelocity)
			{
				velocity.x = maxVelocity;
			}
			else if (velocity.x < 0f - maxVelocity)
			{
				velocity.x = 0f - maxVelocity;
			}
			if (velocity.y > maxVelocity)
			{
				velocity.y = maxVelocity;
			}
			else if (velocity.y < 0f - maxVelocity)
			{
				velocity.y = 0f - maxVelocity;
			}
			if (velocity.z > maxVelocity)
			{
				velocity.z = maxVelocity;
			}
			else if (velocity.z < 0f - maxVelocity)
			{
				velocity.z = 0f - maxVelocity;
			}
			componentInParent2.velocity = velocity;
		}
	}
}
